<template>
  <div id="main">
    <div class="top-box">
      <img @touchstart="gousercenter" class="left-arrow" src="@/assets/书城/shape_u112.png" alt />
      <span>{{username}}</span>
      <div></div>
    </div>
    <div class="midbox">
      <ul>
        <li v-for="(item,index) in talklist" :key="index">
          <p class="time">{{date}}</p>
          <div class="talkingcontent">
            <div></div>
            <div class="talkingbox">
              <p>{{item}}</p>
              <div class="headimg">
                <img src="@/assets/书城/ellipse_24_u3566.png" alt />
              </div>
            </div>
          </div>
        </li>
      </ul>
    </div>
    <div class="bottom">
      <p @touchstart="isshow=true">发送信息...</p>
    </div>
    <div class="hidbox" :class="{showbox:isshow}">
      <div class="inputbox">
        <input type="text" placeholder="发消息" v-model="talktext" />
        <span @touchstart="sedtext">发送</span>
      </div>
      <img width="100%" height="366" src="@/assets/talking/位图_u3697.png" alt />
    </div>
  </div>
</template>

<script>
let nowtime = Date.now();
function getdate(now) {
  let nowday = new Date(now);
  let y = nowday.getFullYear();
  let m = nowday.getMonth() + 1;
  let d = nowday.getDate();
  return (
    y +
    "-" +
    (m < 10 ? "0" + m : m) +
    "-" +
    (d < 10 ? "0" + d : d) +
    " " +
    nowday.toTimeString().substr(0, 5)
  );
}

let talkdate = getdate(nowtime);
export default {
  data() {
    return {
      username: "西瓜",
      date: talkdate,
      userhead: "",
      isshow: false,
      talktext: "",
      talklist: []
    };
  },
  computed: {},
  methods: {
    sedtext() {
      this.isshow = false;
      this.talklist.push(this.talktext);
    },
    gousercenter() {
      this.$router.push(
        {
          path: "/usercenter"
        },
        () => {}
      );
    }
  }
};
</script>

<style lang="less" scoped>
#main {
  .top-box {
    position: fixed;
    top: 0;
    left: 0;
    box-sizing: border-box;
    margin-bottom: 3.5rem;
    width: 100%;
    height: 1.6rem;
    display: flex;
    justify-content: space-between;
    background-color: rgba(255, 255, 255, 1);
    padding: 0 1.5rem;
    padding-top: 4.5rem;
    padding-bottom: 2.5rem;
    height: 5rem;
    z-index: 97;
    .left-arrow {
      width: .9rem;
      height: 1.4rem;
    }
    span {
      font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC";
      font-weight: 650;
      font-style: normal;
      font-size: 1.8rem;
      height: 2.5rem;
      line-height: 2.5rem;
      margin-top: -0.5rem;
    }
  }
  .midbox {
    width: 100%;
    height: 60rem;
    box-sizing: border-box;
    ul {
      list-style-type: none;
      li {
        margin: 1rem 0;
        .time {
          font-family: "PingFangSC-Regular", "PingFang SC";
          font-weight: 400;
          font-style: normal;
          font-size: 1.1rem;
          color: #9e9e9e;
          text-align: center;
        }
        .talkingcontent {
          margin: .5rem 0;
          padding: 0 1.5rem;
          display: flex;
          justify-content: space-between;
          .talkingbox {
            display: flex;
            p {
              padding: 0 .5rem;
              height: 3.4rem;
              text-align: center;
              line-height: 3.4rem;
              font-family: "PingFangSC-Regular", "PingFang SC";
              font-weight: 400;
              font-style: normal;
              font-size: 1.4rem;
              color: #ffffff;
              background: inherit;
              background-color: rgba(65, 200, 114, 1);
              border: none;
              border-radius: .6rem;
              border-top-right-radius: 0rem;
              margin-right: 1.5rem;
            }
            .headimg {
              width: 4.4rem;
              height: 4.4rem;
              background: url("@/assets/talking/mask_u3683.png");
            }
          }
        }
      }
    }
  }
  .bottom {
    width: 100%;
    height: 8.6rem;
    position: relative;
    background: inherit;
    background-color: rgba(255, 255, 255, 1);
    border: none;
    border-radius: 0rem;
    box-shadow: 0rem -0.5rem 1rem rgb(228 228 228 / 35%);
    p {
      position: absolute;
      left: 2rem;
      top: 1.5rem;
      font-family: "PingFangSC-Regular", "PingFang SC";
      font-weight: 400;
      font-style: normal;
      color: #9e9e9e;
      font-size: 1.3rem;
      border-left: .2rem solid rgba(65, 200, 114, 1);
      padding-left: .5rem;
      width: 30rem;
      margin: 0 auto;
    }
  }
  .hidbox {
    box-shadow: 0rem -0.5rem 1rem rgb(228 228 228 / 35%);
    width: 100%;
    height: 41.2rem;
    position: fixed;
    bottom: -100%;
    z-index: 99;
    .inputbox {
      display: flex;
      justify-content: space-around;
      box-sizing: border-box;
      padding: 1rem 0;
      input {
        width: 30.8rem;
        height: 3rem;
        background: inherit;
        background-color: rgba(242, 242, 242, 1);
        box-sizing: border-box;
        border-width: .1rem;
        border-style: solid;
        border-color: rgba(242, 242, 242, 1);
        border-radius: 3rem;
        padding-left: 1.5rem;
        outline: none;
        &::placeholder {
          background-color: transparent;
          font-family: "ArialMT", "Arial";
          font-weight: 400;
          font-style: normal;
          font-size: 1.4rem;
        }
      }
      span {
        width: 4.4rem;
        height: 2.9rem;
        background: inherit;
        background-color: rgba(65, 200, 114, 1);
        border: none;
        border-radius: 10rem;
        -moz-box-shadow: none;
        -webkit-box-shadow: none;
        box-shadow: none;
        font-family: "PingFangSC-Regular", "PingFang SC";
        font-weight: 400;
        font-style: normal;
        color: #ffffff;
        text-align: center;
        line-height: 2.9rem;
        font-size: 1.3rem;
      }
    }
  }
  .showbox {
    animation: showinput 0.5s linear forwards;
  }
  @keyframes showinput {
    0% {
      bottom: -100%;
    }
    100% {
      bottom: 0;
    }
  }
}
</style>